package cn.zs.supply.common.core.web.config;

import cn.zs.supply.common.core.mq.RocketProducer;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;


public class BaseRocketConfig {
    @Value("${rocketmq.producer.groupName}")
    private String groupName;
    @Value("${rocketmq.producer.namesrvAddr}")
    private String namesrvAddr;
    @Value("${rocketmq.producer.maxMessageSize}")
    private int maxMessageSize; //4M
    @Value("${rocketmq.producer.sendMsgTimeout}")
    private int sendMsgTimeout;
    @Value("${rocketmq.producer.sendMsgRetryTimes}")
    private int sendMsgRetryTimes;
    @Value("${rocketmq.topicPrefix}")
    private String topicPrefix;

    @Bean
    public RocketProducer getRocketMQProducer()  {
        return RocketProducer.getInstance(this.topicPrefix, this.namesrvAddr, this.groupName,
                this.maxMessageSize, this.sendMsgTimeout, this.sendMsgRetryTimes);
    }
}
